#include "Inventory.h"

void Inventory::add(Base& obj) {
	Inventory::iterator p = this->search(obj);
	bool found = (p != this->end());
	
	if(!found)
		this->push_back(obj);	
}

void Inventory::del(Base& obj) {
	Inventory::iterator p = this->search(obj);
	bool found = (p != this->end());
	
	if(found)
		this->erase(p);	
}

Inventory::iterator Inventory::search(Base& obj) {
	Inventory::iterator first = this->begin();
	Inventory::iterator last  = this->end();

	for( ; first != last; first++)
		if(first->getObjectID() == obj.getObjectID())
			break;
	
	return first;
}
